package letsjava.pattern.proxy;

public class FormProxy {
	Form a = new Form();
	FormPermission b;
	public void setPermission(FormPermission b){
		this.b = b;
	}
	public void insert(){
		if(b.allow("insert")){
			a.insert();
		}else{
			System.out.println("you are not allowed to call insert");
		}
	}
	
	public static void main(String[] args){
		FormPermission a = new FormPermission(3);
		FormPermission b = new FormPermission(6);
		
		FormProxy p = new FormProxy();
		p.setPermission(a);
		p.insert();
		
		p.setPermission(b);
		p.insert();
	}
}
